package office;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @Author: youdao.hww
 * @Date: 9/13/24
 * @Desc:
 */
public class PatientSorter {

    public static void main(String[] args) {
        List<Patient> patientList = new ArrayList<>();
        patientList.add(new Patient("责任三", 2));
        patientList.add(new Patient("责任一", 3));
        patientList.add(new Patient("责任二", 1));
        patientList.add(new Patient("责任一", 1));
        patientList.add(new Patient("责任二", 2));
        patientList.add(new Patient("责任三", 3));

        // 对列表进行排序
        sortPatients(patientList);

        // 打印排序后的结果
        patientList.forEach(patient -> System.out.println(patient.getGroupName() + ": " + patient.getBedSortNumber()));
    }

    private static void sortPatients(List<Patient> patientList) {
        // 定义排序规则
        Comparator<Patient> comparator = Comparator
                .comparing(Patient::getGroupName) // 首先按groupName排序
                .thenComparing(Patient::getBedSortNumber); // 再按bedSortNumber排序

        // 对列表进行排序
        patientList.sort(comparator);
    }
}
